<template>
	<view class="container">
		<view class="topPart">
			<view class="headAndName" v-if="infomation==null || infomation==''" @click="goLogin">
				<image class="head"
					src="https://thirdwx.qlogo.cn/mmopen/vi_32/Q3ZWTgJyTiaCn44pich2EqzfKTPmS2CqGlZvNUhxcSCmciaDx0OjpS5712GjkribyWZTcZjQ6ux73ttfSzTS4uJUuA/132"
					mode=""></image>
				<view class="nametop">
					<view class="name">登录</view>
					<view class="biaoyu">登录迎接第一束鲜花叭~</view>
				</view>
			</view>
			<view class="headAndName" v-else>
				<image class="head" :src="infomation.avatarUrl" mode=""></image>
				<view class="nametop">
					<view class="name">{{infomation.nickName}}</view>
					<view class="biaoyu">送自己一束花是终身浪漫的开始</view>
				</view>
			</view>
		</view>

		<view class="secondPart">
			<view class="top" @click="goall">
				<view class="blod">我的订单</view>
				<view class="small">全部订单</view>
				<image class="right" src="../../static/img/rightline.png" mode=""></image>
			</view>
			<view class="line"></view>
			<view class="bottom">
				<view class="part" @click="goall">
					<image class="img" src="../../static/img/nopay.png" mode=""></image>
					<view class="">待付款</view>
				</view>
				<view class="part" @click="goall">
					<image class="img" src="../../static/img/getIt.png" mode=""></image>
					<view class="">已签收</view>
				</view>
				<view class="part" @click="goEvaluate">
					<image class="img" src="../../static/img/noWrite.png" mode=""></image>
					<view class="">评价</view>
				</view>
			</view>
		</view>

		<view class="MyPrice" v-if="org==1">
			<view class="top" @click="goall">
				<view class="blod">我的资金</view>
				<image class="right" src="../../static/img/rightline.png" mode=""></image>
			</view>
			<view class="price">*****</view>
			<view class="line"></view>
			<view class="bottom">
				<view class="part" @click="CPublish">
					<view>我发布的</view>
				</view>
				<view class="part" @click="CSell">
					<view>我卖出的</view>
				</view>
				<view class="part" @click="cEvaluate">
					<view>评价</view>
				</view>
				<view class="part" @click="cAdd">
					<view>发布</view>
				</view>
			</view>
		</view>

		<view class="trePart">
			<view class="part" @click="goAdress">
				<image class="img" src="../../static/img/address.png" mode=""></image>
				<text class="txt">地址管理</text>
				<image class="right" src="../../static/img/rightline.png" mode=""></image>
			</view>
			<view class="part" @click="gotalk">
				<image class="img" src="../../static/img/talk.png" mode=""></image>
				<text class="txt">客服与帮助</text>
				<image class="right" src="../../static/img/rightline.png" mode=""></image>
			</view>
			<view class="part" @click="golog">
				<image class="img" src="../../static/img/love.png" mode=""></image>
				<text class="txt">心意小记</text>
				<image class="right" src="../../static/img/rightline.png" mode=""></image>
			</view>
			<view class="part" @click="GoChangeRole(org)" v-if="org==1">
				<image class="img" src="../../static/img/joleLogo.png" mode=""></image>
				<!-- <text class="txt" v-if="org==0">成为商家</text> -->
				<text class="txt">切换为普通用户</text>
				<image class="right" src="../../static/img/rightline.png" mode=""></image>
			</view>
			<view class="part" @click="gopromise">
				<image class="img" src="../../static/img/pro.png" mode=""></image>
				<text class="txt">用户协议</text>
				<image class="right" src="../../static/img/rightline.png" mode=""></image>
			</view>
			<view class="part" @click="goys">
				<image class="img" src="../../static/img/ys.png" mode=""></image>
				<text class="txt">隐私政策</text>
				<image class="right" src="../../static/img/rightline.png" mode=""></image>
			</view>
			<view class="part" @click="ClearData">
				<image class="img" src="../../static/img/getout.png" mode=""></image>
				<text class="txt">退出登录</text>
				<image class="right" src="../../static/img/rightline.png" mode=""></image>
			</view>
		</view>
		<view style="height: 40rpx;"></view>
	</view>
</template>

<script>
	export default {
		data() {
			return {
				statusBarHeight: null,
				org: 0, //1代表商家 0普通用户
				infomation: null
			}
		},
		onLoad() {

			var _this = this;
			// 获取手机状态栏高度
			uni.getSystemInfo({
				success: function(data) {
					// 将其赋值给this
					_this.statusBarHeight = data.statusBarHeight;
				}
			})

		},
		onShow() {
			this.infomation = uni.getStorageSync('UserInformation')
			this.org = this.infomation.org

			var oo = uni.getStorageSync('ChangeRole')
			if (oo.ChangeOrg == undefined) {} else {
				this.org = oo.ChangeOrg
			}

		},
		methods: {
			goLogin() {
				uni.navigateTo({
					url: '/pages/login/login'
				})
			},
			goall() {
				if (this.infomation.usertoken == undefined) {

					uni.navigateTo({
						url: '/pages/login/login'
					})
					return
				}
				uni.navigateTo({
					url: '/pages-me/MyOrder/MyOrder'
				})
			},
			goEvaluate() {
				if (this.infomation.usertoken == undefined) {

					uni.navigateTo({
						url: '/pages/login/login'
					})
					return
				}
				uni.navigateTo({
					url: '/pages-me/MyEvaluate/MyEvaluate'
				})
			},
			gotalk() {
				uni.navigateTo({
					url: '/pages-me/MyTalkAndHelp/MyTalkAndHelp'
				})
			},
			goAdress() {
				if (this.infomation.usertoken == undefined) {

					uni.navigateTo({
						url: '/pages/login/login'
					})
					return
				}
				uni.navigateTo({
					url: '/pages-me/MyAdress/MyAdress'
				})
			},
			cEvaluate() {
				uni.navigateTo({
					url: '/pages-me/CEvaluate/CEvaluate'
				})
			},
			cAdd() {
				if (this.infomation.usertoken == undefined) {

					uni.navigateTo({
						url: '/pages/login/login'
					})
					return
				}
				uni.navigateTo({
					url: '/pages-me/CAdd/CAdd'
				})
			},
			golog() {
				if (this.infomation.usertoken == undefined) {

					uni.navigateTo({
						url: '/pages/login/login'
					})
					return
				}
				uni.navigateTo({
					url: '/pages-me/MyLog/MyLog'
				})
			},
			CPublish() {
				if (this.infomation.usertoken == undefined) {

					uni.navigateTo({
						url: '/pages/login/login'
					})
					return
				}
				uni.navigateTo({
					url: '/pages-me/CPublish/CPublish'
				})
			},
			CSell() {
				if (this.infomation.usertoken == undefined) {

					uni.navigateTo({
						url: '/pages/login/login'
					})
					return
				}
				uni.navigateTo({
					url: '/pages-me/CSell/CSell'
				})
			},
			gopromise() {
				uni.navigateTo({
					url: '/pages-me/MyPromise/MyPromise'
				})
			},
			ClearData() { //退出登录
				this.requestfs({
					url: '/user/loginOut',
					Authorization: this.infomation.usertoken,
				}).then(res => {
					if (res.data.msg == "success") {
						uni.clearStorageSync('UserInformation')
						this.infomation = null
						this.org = 0
						uni.showToast({
							title: '成功退出登录',
							icon: 'success'
						})
					}
				})
			},
			goys() {
				uni.navigateTo({
					url: '/pages-me/MyGoys/MyGoys'
				})
			},
			GoChangeRole(org) {
				uni.navigateTo({
					url: '/pages-me/ChangeRole/ChangeRole?org=' + org
				})
			}
		}
	}
</script>

<style lang="scss">
	.container {
		width: 750rpx;
		background: #f3f5f7;
		position: relative;
		height: auto;
		min-height: 100vh;

		.trePart {
			background: #ffffff;
			border-radius: 12rpx;
			margin: 0 5%;
			padding: 0 4%;

			.part {
				display: flex;
				line-height: 100rpx;
				border-bottom: 1px solid #f3f5f7;

				.img {
					width: 50rpx;
					height: 50rpx;
					margin-top: 30rpx;
				}

				.txt {
					margin-left: 18rpx;
					width: 84%;
				}

				.right {
					width: 32rpx;
					height: 32rpx;
					margin-top: 34rpx;
				}
			}
		}

		.MyPrice {
			background: #ffffff;
			width: 90%;
			height: 230rpx;
			border-radius: 12rpx;
			margin: -10rpx 5% 30rpx 5%;

			.price {
				font-weight: bold;
				width: 88%;
				margin: 0 auto;
				font-size: 40rpx;
			}

			.bottom {
				display: flex;

				.part {
					width: 33%;
					text-align: center;
					font-size: 26rpx;
					margin-top: 18rpx;
				}
			}

			.line {
				height: 1px;
				width: 92%;
				background: #f3f5f7;
				margin: 0 auto;
			}

			.top {
				width: 92%;
				margin: 0 auto;
				display: flex;
				line-height: 100rpx;

				.blod {
					font-weight: bold;
					font-size: 34rpx;
					width: 70%;
				}

				.small {
					color: #656768;
					font-size: 28rpx;
				}

				.right {
					width: 32rpx;
					height: 32rpx;
					margin: 34rpx 0 0 100rpx;
				}

			}


		}

		.secondPart {
			background: #ffffff;
			width: 90%;
			height: 230rpx;
			border-radius: 12rpx;
			position: absolute;
			left: 5%;
			top: 270rpx;

			.bottom {
				display: flex;

				.part {
					width: 33%;
					text-align: center;
					font-size: 26rpx;
					margin-top: 18rpx;

					.img {
						width: 48rpx;
						height: 48rpx;
					}
				}
			}

			.line {
				height: 1px;
				width: 92%;
				background: #f3f5f7;
				margin: 0 auto;
			}

			.top {
				width: 92%;
				margin: 0 auto;
				display: flex;
				line-height: 100rpx;

				.blod {
					font-weight: bold;
					font-size: 34rpx;
					width: 70%;
				}

				.small {
					color: #656768;
					font-size: 28rpx;
				}

				.right {
					width: 32rpx;
					height: 32rpx;
					margin: 34rpx 0 0 10rpx;
				}

			}
		}

		.topPart {
			// margin-top: 80rpx;
			width: 100%;
			height: 540rpx;
			background-image: linear-gradient(to top, rgba(255, 0, 0, 0), rgba(246, 239, 255, 1));

			.headAndName {
				width: 100%;
				padding-top: 100rpx;
				display: flex;

				.nametop {
					padding: 10rpx 20rpx;

					.name {
						font-weight: bold;
						font-size: 34rpx;
					}

					.biaoyu {
						font-size: 22rpx;
						margin-top: 8rpx;
					}
				}

				.head {
					width: 100rpx;
					height: 100rpx;
					border-radius: 50%;
					margin-left: 60rpx;
				}
			}
		}

		.wrap {
			position: fixed;
			background: #ffffff;
			width: 100%;
			height: 80rpx;
			line-height: 80rpx;
			top: 0;
			left: 0;

			.top {
				margin-left: $uni-spacing-row-sm;
				margin-right: $uni-spacing-row-sm;
				text-align: center;

			}
		}

	}
</style>
